import http from './interface'

export {
	http
}
/**
 * 将业务所有接口统一起来便于维护
 * 如果项目很大可以将 url 独立成文件，接口分成不同的模块
 * 
 */

// 单独导出(测试接口) import {test} from '@/common/vmeitime-http/'

///微信登录
export const familyWeChartMobileLogin = (data) => {
	
	/* http.config.baseUrl = "http://localhost:8080/api/"
	//设置请求前拦截器
	http.interceptor.request = (config) => {
		config.header = {
			"token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
		}
	} */
	//设置请求结束后拦截器
	http.interceptor.response = (response) => {
		console.log('个性化response....')
		//判断返回状态 执行相应操作
		return response;
	}
	
	if(process.env.NODE_ENV === 'development'){
		data.weChatIsDevState = true
	    console.log('开发环境')
	}else{
	    console.log('生产环境')
	}
    return http.request({
        method: 'POST', 
        url: 'api/v1/family/familyWeChartMobileLogin',
		dataType: 'json',
        data,
    })
}

///获取学校信息
export const findCampus = (parms) => {
	return http.request({
        method: 'GET', 
        url: 'api/v1/campus/findCampus' + parms,
		dataType: 'json',
    })
}

///账号登录
export const teacherAccountLogin = (data) => {
    return http.request({
        method: 'POST', 
        url: 'api/v1/teacher/teacherAccountMobileLogin',
		dataType: 'json',
        data,
    })
}

///获取验证码
export const getPicCode = () => {
	return http.request({
        method: 'GET', 
        url: 'getPicCode',
		dataType: 'json',
    })
}

///查询登陆用户信息
export const selectLoginUserInfo = (data) => {
    return http.request({
        method: 'POST', 
        url: 'api/v1/power/selectLoginUserInfo',
		dataType: 'json',
        data,
    })
}

///查询登陆用户菜单
export const selectLoginUserMenu = (data) => {
    return http.request({
        method: 'POST', 
        url: 'api/v1/power/selectLoginUserMenu',
		dataType: 'json',
        data,
    })
}

///查询登陆用户菜单
export const logout = (parms) => {
    return http.request({
        method: 'POST', 
        url: '/api/v1/teacher/unBindWeChat' + parms,
		dataType: 'json',
        // data,
    })
}

///查询年级树
export const findGradeTreeList = (data) => {
    return http.request({
        method: 'POST', 
        url: '/api/v1/grade/findGradeTreeList',
		dataType: 'json',
        data,
    })
}

///查询任课班级
export const selectClassOfLoginTeacher = (data) => {
    return http.request({
        method: 'POST', 
        url: '/api/v1/course/selectClassOfLoginTeacher',
		dataType: 'json',
        data,
    })
}

// 默认全部导出  import api from '@/common/vmeitime-http/'
export default {
	familyWeChartMobileLogin,
	teacherAccountLogin,
    getPicCode,
	findCampus,
	selectLoginUserInfo,
	selectLoginUserMenu,
	logout,
	findGradeTreeList,
	selectClassOfLoginTeacher
}